//维修记录
import { Component, OnInit } from '@angular/core';
import { NzNotificationService,NzModalService, NzModalSubject } from 'ng-zorro-antd';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { HttpServcie } from '../../../service/http.service';
import { Config } from '../../../service/config';
import { MaintenanceRecord } from './bean/maintenance-record.bean';
import { el } from "@angular/platform-browser/testing/src/browser_util";
import { FormBuilder, FormGroup, Validators } from '@angular/forms';

@Component({
	selector: 'maintenance-record',
	templateUrl: 'maintenance-record.html',
	styleUrls: ['maintenance-record.scss']
})
export class MaintenancePage implements OnInit {
	 data: any;
	//接收参数
	 maintenanceBean: MaintenanceRecord = new MaintenanceRecord();
	//返回的集合
	 list: any = [];
	//总页数
	 total: string;
	//多选框
	 allChecked: any = false;
	//多选框
	 indeterminate: any = false;
	constructor(
		private httpServcie: HttpServcie,
		private router: Router,
		private _notification: NzNotificationService,
		private nsub: NzModalSubject,
		private modalService: NzModalService,
		private route:ActivatedRoute
	) {
	}
	ngOnInit() {
		this.maintenanceBean.pageSize = 10;
        this.maintenanceBean.currentPage = 1;
		this.route.paramMap.subscribe(data=>{
            //查询电梯的信息
            this.maintenanceBean.elevatorId =  data.get("elevatorId");
            this.query();
        });

	}

	query(){
		this.httpServcie.queryByElevatorList(this.maintenanceBean).subscribe(datas=>{
			if(datas.status==200){
				this.list = datas.data.list;
				this.total = datas.data.total;
			}

		})
	}
	//table加载数据时
	displayDataChange($event) {
		this.list = $event;
		this.refreshStatus();
	}
	//当前页
	nzPageIndexClickChange(event) {
		this.maintenanceBean.currentPage = event;
		this.query();
	}
	  //全选
	checkAll(value) {
	if (value) {
		this.list.forEach(data => {
		if (!data.disabled) {
			data.checked = true;
		}
		});
	} else {
		this.list.forEach(data => data.checked = false);
	}
	};

	    //分页
	nzPageSizeChange(event) {
		this.maintenanceBean.pageSize = event;
		this.maintenanceBean.currentPage = 1;
		this.query();
	
	}
	//重置选择框
	refreshStatus() {

	}
	 //输入框的方法
	nzPageIndexChange(event) {
		
	}
	//点击维修记录详情跳转
	toDetail(param){
		 this.router.navigate(['/home/maintenance-detail',{id:param}])
	}
	toBack(){
		window.history.back();
	   // this.router.navigate
	}
}


